package com.demo.androidgame.samgukji_hit;

import com.demo.androidgame.fx.DynamicGameObject;

public class Hero extends DynamicGameObject{

	public static final int Hero_state_stop = 0;
	public static final int Hero_state_move = 1;
	public static final int Hero_state_fire = 2;
	public static final int Hero_state_moveAndfire = 3;
	
	//public static int BOB_STATE = 3;				//테스트용


//	public static final float Hero_JUMP_VELOCITY = 11;    //초당 11단위로 올라감
//    public static final float Hero_RUN_VELOCITY = 20;
//    public static final float Hero_MOVE_VELOCITY = 150;	//좌, 우 속도는 20
    public static final float Hero_WIDTH = 100;
    public static final float Hero_HEIGHT = 100;

    int state;
    float stateTime; 
	
	public Hero(float x, float y) {
		super(x, y, Hero_WIDTH, Hero_HEIGHT);
		state = Hero_state_stop;
		stateTime = 0;
	}
	
	public void update(float deltaTime) {
		//BOB_STATE = state;	//테스트용
    	
    	//x, y -> 좌우상하 다 움직일 수 있도록
//        velocity.add(HeroStage.gravity.x * deltaTime, HeroStage.gravity.y * deltaTime);		//시간(프레임) 수많큼 나누므로 deltaTime을 곱해줌
//        position.add(-(velocity.x * deltaTime), velocity.y * deltaTime);
        bounds.lowerLeft.set(position).sub(bounds.width / 2, bounds.height / 2);
	
//        if(velocity.y < 64 && state != Hero_state_fire) {		//BOB_STATE_HIT : 땅을 밟은 상태
//        	if(state != Hero_state_fail) {					//떨어지는 상태
//                state = Hero_state_fail;
//                stateTime = 0;
//            }
//        }
//        if(state != Hero_state_move &&state != Hero_state_fire && state != Hero_state_moveAndfire) {
//        	state = Hero_state_stop;
//        	stateTime = 0;
//        }
        
        if(position.x <= 50)									//맵탈출 방지
            //position.x = World.WORLD_WIDTH;
        	position.x = 50;
        if(position.x >= HeroStage.WORLD_WIDTH - 50)
        	position.x = HeroStage.WORLD_WIDTH - 50;
            //position.x = 0;
        if(position.y <= 120)
        	position.y = 120;
        if(position.y >= 360)
        	position.y = 360;
        if (state == Hero_state_move) {
        	stateTime += deltaTime + 0.1f;
        } else {
        	stateTime += deltaTime + 0.03f;
        }
    }
	
	public void heroStop() {
		state = Hero_state_stop;
		stateTime = 0;
	}
	public void heroMove() {
		state = Hero_state_move;
		stateTime = 0;
		
//		stateTime += deltaTime;
	}
	public void heroFire() {
		state = Hero_state_fire;
		stateTime = 0;
	}
	public void heroMove_Fire() {
		state = Hero_state_moveAndfire;
		stateTime = 0;
	}
	

}
